<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.text.*"%>
<%!String content = "My name is JSP and Servlet";

	public int GetLength() {
		return content.length();
	}

	public String GetWord() {
		String GetStr = "";
		int index = content.indexOf(" ");
		GetStr = content.substring(0, index);
		return GetStr;
	}

	public String indexOfcontent() {
		String indexStr = "";
		String GetStr = "";
		for (int i = 0; i < GetLength(); i++) {
			int index = content.indexOf(" ");

			if (i != index) {
				GetStr = content.substring(i, i + 1);
				indexStr += GetStr + ":";
				indexStr += i;
				indexStr += " ";

			}

		}
		return indexStr;
	}%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<p>
		字符串长度：<%
		out.println(GetLength());
	%><%-- <%=GetLength()  --%>
	</p>
	<p>
		字符串的第一个字符：<%
		out.println(content.subSequence(0, 1));
	%>
		<%-- <%=content.subSequence(0, 1) %> --%>
	</p>
	<p>
		字符串的最后一个字符：<%
		out.println(content.subSequence(GetLength() - 1, GetLength()));
	%><%-- <%=content.subSequence(GetLength()-1,GetLength()) %> --%>
	</p>
	<p>
		字符串的第一个单词：<%
		out.println(GetWord());
	%><%-- <%=GetWord() %> --%>
	</p>
	<p>
		字符串 JSP 的位置（从 0 开始编号的位置）：<%
		out.println(indexOfcontent());
	%><%-- <%=indexOfcontent() %> --%>
	</p>

</body>
</html>